<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="ManhattanConnectionRouter.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>ManhattanConnectionRouter.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'ManhattanConnectionRouter.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="draw2d/ManhattanConnectionRouter.html">draw2d.ManhattanConnectionRouter</a></b></td>
    <td>Routes a <a href="../draw2d/Connection.html#">draw2d.Connection</a>, possibly using a constraint.</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/* This notice must be untouched at all times.

FreeGroup Draw2D 0.9.26
The latest version is available at
http://www.freegroup.de

Copyright (c) 2006 Andreas Herz. All rights reserved.
Created 5. 11. 2006 by Andreas Herz (Web: http://www.freegroup.de )

LICENSE: LGPL

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA,
or see http://www.gnu.org/copyleft/lesser.html
*/</span>

<span class="comment">/**
 * <span class="attrib">@class</span> Routes a {<span class="attrib">@link</span> draw2d.Connection}, possibly using a constraint.
 *
 * <span class="attrib">@version</span> 0.9.26
 * <span class="attrib">@author</span> Andreas Herz
 * <span class="attrib">@constructor</span>
 */</span>
draw2d.ManhattanConnectionRouter=<span class="reserved">function</span>()
{
   <span class="reserved">this</span>.MINDIST = 20;
};

draw2d.ManhattanConnectionRouter.<span class="reserved">prototype</span> = new draw2d.ConnectionRouter();
draw2d.ManhattanConnectionRouter.<span class="reserved">prototype</span>.type=<span class="literal">"draw2d.ManhattanConnectionRouter"</span>;



<span class="comment">/**
 * <span class="attrib">@see</span> draw2d.ConnectionRouter#route(Connection)
 */</span>
draw2d.ManhattanConnectionRouter.<span class="reserved">prototype</span>.route=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Connection*/</span> conn)
{
   var fromPt  = conn.getStartPoint();
   var fromDir = <span class="reserved">this</span>.getStartDirection(conn);

   var toPt    = conn.getEndPoint();
   var toDir   = <span class="reserved">this</span>.getEndDirection(conn);

   <span class="comment">// draw a line between the two points.</span>
   <span class="reserved">this</span>._route(conn,toPt, toDir, fromPt, fromDir);
};

draw2d.ManhattanConnectionRouter.<span class="reserved">prototype</span>._route=<span class="reserved">function</span>(<span class="comment">/*:draw2d.Connection*/</span> conn,<span class="comment">/*:draw2d.Point*/</span> fromPt, <span class="comment">/*:int*/</span>fromDir, <span class="comment">/*:draw2d.Point*/</span>toPt, <span class="comment">/*:int*/</span>toDir)
{
   var TOL     = 0.1;
   var TOLxTOL = 0.01;

   <span class="comment">// fromPt is an x,y to start from.  </span>
   <span class="comment">// fromDir is an angle that the first link must </span>
   <span class="comment">//</span>
   var UP   = 0;
   var RIGHT= 1;
   var DOWN = 2;
   var LEFT = 3;

   var xDiff = fromPt.x - toPt.x;
   var yDiff = fromPt.y - toPt.y;
   var point;
   var dir;

   <span class="reserved">if</span> (((xDiff * xDiff) &lt; (TOLxTOL)) &amp;&amp; ((yDiff * yDiff) &lt; (TOLxTOL))) 
   {
      conn.addPoint(new draw2d.Point(toPt.x, toPt.y));
      <span class="reserved">return</span>;
   }

   <span class="reserved">if</span> (fromDir == LEFT) 
   {
      <span class="reserved">if</span> ((xDiff &gt; 0) &amp;&amp; ((yDiff * yDiff) &lt; TOL) &amp;&amp; (toDir === RIGHT))
      {
         point = toPt;
         dir = toDir;
      } 
      <span class="reserved">else</span> 
      {
         <span class="reserved">if</span> (xDiff &lt; 0) 
         {
            point = new draw2d.Point(fromPt.x - <span class="reserved">this</span>.MINDIST, fromPt.y);
         }
         <span class="reserved">else</span> <span class="reserved">if</span> (((yDiff &gt; 0) &amp;&amp; (toDir === DOWN)) || ((yDiff &lt; 0) &amp;&amp; (toDir == UP))) 
         {
            point = new draw2d.Point(toPt.x, fromPt.y);
         }
         <span class="reserved">else</span> <span class="reserved">if</span> (fromDir == toDir)
         {
            var pos = Math.min(fromPt.x, toPt.x) - <span class="reserved">this</span>.MINDIST;
            point = new draw2d.Point(pos, fromPt.y);
         }
         <span class="reserved">else</span>
         {
            point = new draw2d.Point(fromPt.x - (xDiff / 2), fromPt.y);
         }

         <span class="reserved">if</span> (yDiff &gt; 0) 
         {
            dir = UP;
         }
         <span class="reserved">else</span>
         {
            dir = DOWN;
         }
      }
   }
   <span class="reserved">else</span> <span class="reserved">if</span> (fromDir == RIGHT) 
   {
      <span class="reserved">if</span> ((xDiff &lt; 0) &amp;&amp; ((yDiff * yDiff) &lt; TOL)&amp;&amp; (toDir === LEFT)) 
      {
         point = toPt;
         dir = toDir;
      } 
      <span class="reserved">else</span> 
      {
         <span class="reserved">if</span> (xDiff &gt; 0) 
         {
           point = new draw2d.Point(fromPt.x + <span class="reserved">this</span>.MINDIST, fromPt.y);
         } 
         <span class="reserved">else</span> <span class="reserved">if</span> (((yDiff &gt; 0) &amp;&amp; (toDir === DOWN)) || ((yDiff &lt; 0) &amp;&amp; (toDir === UP))) 
         {
            point = new draw2d.Point(toPt.x, fromPt.y);
         } 
         <span class="reserved">else</span> <span class="reserved">if</span> (fromDir == toDir) 
         {
            var pos = Math.max(fromPt.x, toPt.x) + <span class="reserved">this</span>.MINDIST;
            point = new draw2d.Point(pos, fromPt.y);
         } 
         <span class="reserved">else</span> 
         {
               point = new draw2d.Point(fromPt.x - (xDiff / 2), fromPt.y);
         }

         <span class="reserved">if</span> (yDiff &gt; 0)
         {
            dir = UP;
         }
         <span class="reserved">else</span>
         {
            dir = DOWN;
         }
      }
   } 
   <span class="reserved">else</span> <span class="reserved">if</span> (fromDir == DOWN) 
   {
      <span class="reserved">if</span> (((xDiff * xDiff) &lt; TOL) &amp;&amp; (yDiff &lt; 0)&amp;&amp; (toDir == UP)) 
      {
         point = toPt;
         dir = toDir;
      } 
      <span class="reserved">else</span> 
      {
         <span class="reserved">if</span> (yDiff &gt; 0) 
         {
            point = new draw2d.Point(fromPt.x, fromPt.y + <span class="reserved">this</span>.MINDIST);
         } 
         <span class="reserved">else</span> <span class="reserved">if</span> (((xDiff &gt; 0) &amp;&amp; (toDir === RIGHT)) || ((xDiff &lt; 0) &amp;&amp; (toDir === LEFT))) 
         {
           point = new draw2d.Point(fromPt.x, toPt.y);
         } 
         <span class="reserved">else</span> <span class="reserved">if</span> (fromDir === toDir) 
         {
            var pos = Math.max(fromPt.y, toPt.y) + <span class="reserved">this</span>.MINDIST;
            point = new draw2d.Point(fromPt.x, pos);
         } 
         <span class="reserved">else</span> 
         {
            point = new draw2d.Point(fromPt.x, fromPt.y - (yDiff / 2));
         }

         <span class="reserved">if</span> (xDiff &gt; 0) 
         {
            dir = LEFT;
         }
         <span class="reserved">else</span> 
         {
            dir = RIGHT;
         }
      }
   } 
   <span class="reserved">else</span> <span class="reserved">if</span> (fromDir == UP) 
   {
      <span class="reserved">if</span> (((xDiff * xDiff) &lt; TOL) &amp;&amp; (yDiff &gt; 0) &amp;&amp; (toDir === DOWN))
      {
         point = toPt;
         dir = toDir;
      } 
      <span class="reserved">else</span> 
      {
         <span class="reserved">if</span> (yDiff &lt; 0) 
         {
            point = new draw2d.Point(fromPt.x, fromPt.y - <span class="reserved">this</span>.MINDIST);
         } 
         <span class="reserved">else</span> <span class="reserved">if</span> (((xDiff &gt; 0) &amp;&amp; (toDir === RIGHT)) || ((xDiff &lt; 0) &amp;&amp; (toDir === LEFT))) 
         {
            point = new draw2d.Point(fromPt.x, toPt.y);
         } 
         <span class="reserved">else</span> <span class="reserved">if</span> (fromDir === toDir) 
         {
            var pos = Math.min(fromPt.y, toPt.y) - <span class="reserved">this</span>.MINDIST;
            point = new draw2d.Point(fromPt.x, pos);
         } 
         <span class="reserved">else</span> 
         {
            point = new draw2d.Point(fromPt.x, fromPt.y - (yDiff / 2));
         }

         <span class="reserved">if</span> (xDiff &gt; 0)
         {
            dir = LEFT;
         }
         <span class="reserved">else</span>
         {
            dir = RIGHT;
         }
      }
   }
   <span class="reserved">this</span>._route(conn,point, dir, toPt, toDir);
   conn.addPoint(fromPt);
}</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Mon Nov 14 13:45:39 2011</div>
</body>
</html>
